package com.example.sort.entity;

import io.swagger.annotations.ApiModel;
import lombok.Data;

import java.util.Objects;

/**
 * @email 1014686014@qq.com
 * @author:liukaiting
 * @date: 2022/4/19
 */
@Data
@ApiModel("空余的点位")
public class FreeNode extends BaseInfo{
    public FreeNode(Float nodeX, Float nodeY, Float length, Float width) {
        this.nodeX = nodeX;
        this.nodeY = nodeY;
        this.length = length;
        this.width = width;
        this.nodeEndX = nodeX+length;
        this.nodeEndY = nodeY+width;
    }

    public FreeNode(Float nodeX, Float nodeY) {
        this.nodeX = nodeX;
        this.nodeY = nodeY;
    }

    public FreeNode() {}

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        FreeNode freeNode = (FreeNode) o;
        return Objects.equals(getNodeX(), freeNode.getNodeX()) &&
                Objects.equals(getNodeY(), freeNode.getNodeY()) &&
                Objects.equals(getLength(), freeNode.getLength()) &&
                Objects.equals(getWidth(), freeNode.getWidth());
    }

    @Override
    public int hashCode() {
        return Objects.hash(getNodeX(),";", getNodeY(),";", getLength(),";", getWidth());
    }
}
